How to cast/convert form Object in an byte[] array
        Posted  
        
            by 
                maddash
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by maddash
        
        
        
        Published on 2012-10-01T08:22:28Z
        Indexed on 
            2012/10/01
            9:37 UTC
        
        
        Read the original article
        Hit count: 191
        
I've got a maybe simple problem, but at the moment I am not able to solve it.
I have an Object and I need to convert it into a byte[].
public byte[] GetMapiPropertyBytes(string propIdentifier)
{
    return (byte[])this.GetMapiProperty(propIdentifier); //InvalidCastException 
}
Exception:
Unable to cast COM object of type 'System.__ComObject' to class type 'System.Byte[]'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.
So far so good - I've tried to serialize it, but I got another exception - NOT serializable
Could someone help me? I need a method to convert it...
© Stack Overflow or respective owner